package com.sdx.console.plan.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.sdx.console.plan.dao.TDPlanningDataDao;
import com.sdx.console.plan.entity.TDPlanningData;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 招生计划 Service
 */

@Service
@Transactional
public class TDPlanningDataService extends BaseService<TDPlanningData>{

    @Resource
	private TDPlanningDataDao tDPlanningDataDao;

    public PageQuery<TDPlanningData>queryByCondition(PageQuery query){
        PageQuery ret =  tDPlanningDataDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelTDPlanningData(List<String> ids,String tablename){
        try {
            tDPlanningDataDao.batchDelTDPlanningDataByIds(ids,tablename );
        } catch (Exception e) {
            throw new PlatformException("批量删除招生计划失败", e);
        }
    }

	public List<TDPlanningData> all() {
		return tDPlanningDataDao.all();
		}

    public List<TDPlanningData> selectProvince(){
        return tDPlanningDataDao.selectProvince();
    }
    public List<TDPlanningData> selectBaseUniv( Map<String,Object> map){
        return tDPlanningDataDao.selectBaseUniv(map);
    }
    public List<TDPlanningData> selectBatch( Map<String,Object> map){
        return tDPlanningDataDao.selectBatch(map);
    }
    public List<TDPlanningData> selectMajor( Map<String,Object> map){
        return tDPlanningDataDao.selectMajor(map);
    }

    public List<TDPlanningData> selectTDPlanningData( Map<String,Object> map){

        return tDPlanningDataDao.selectTDPlanningData(map);
    }

    public void insertPlanData(TDPlanningData plan){
        tDPlanningDataDao.insertPlanData(plan);
    }

    public Integer selectMajorId(String majorName,Integer hasRegular){
        Integer majorId = tDPlanningDataDao.selectMajorId(majorName, hasRegular);
        if(majorId == null){
            majorId = tDPlanningDataDao.selectSubclassId(majorName, hasRegular);
        }
        return majorId;
    }

    public int selectPlanDataCount(TDPlanningData plan){
        return tDPlanningDataDao.selectPlanDataCount(plan);
    }

    public List<TDPlanningData>  selectUniv() {
        return tDPlanningDataDao.selectUniv();
    }

    public void updatePlanData(TDPlanningData tDPlanningData) {
         tDPlanningDataDao.updatePlanData(tDPlanningData);
    }

    public TDPlanningData queryPlanDataById(Integer id, String tablename) {
        return tDPlanningDataDao.queryPlanDataById(id,tablename);
    }
}